<template>
	<view class="content">
		<nav-bar title="天业数智ERP控制台" />
		<view class="icon-menu">
			<view class="menu_item" v-for="item in menu_list" :key="item.text">
				<view class="item_tit">{{ item.text }}</view>
				<view class="icon_content">
					<view class="icon_item" v-for="icon in item.childrens" :key="icon.path"
						@click="goPoster(icon.path, icon.text)">
						<image class="img" :src="icon.img" style="width: 40%;" mode="widthFix" />
						<view class="text">{{ icon.text }}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue';
const routes = [
	{
		text: '基础数据',
		path: '/views/clientt',
		role: ['20101', '20102', '20103', '20104', '20105', '20106', '20201', '20202', '20203', '20204', '20205',
			'20206', '20301', '20302', '20303', '20306', '20401', '20402', '20403', '20406', '20501', '20502', '20503', '20601', '20602', '20603'],
		childrens: [
			{
				text: '产品管理',
				img: '../../static/product.png',
				path: '/views/dataa/da_product/index',
				role: ['20101', '20102', '20103', '20104', '20105', '20106'],
			}, {
				text: 'BOM物料',
				img: '../../static/product.png',
				path: '/views/dataa/da_bom/index',
				role: ['20201', '20202', '20203', '20204', '20205', '20206'],
			}, {
				text: '货品分类',
				img: '../../static/product.png',
				path: '/views/dataa/da_classify/index',
				role: ['20301', '20302', '20303', '20306'],
			}, {
				text: '计量单位',
				img: '../../static/product.png',
				path: '/views/dataa/da_unit/index',
				role: ['20401', '20402', '20403', '20406'],
			}, {
				text: '供应商管理',
				img: '../../static/product.png',
				path: '/views/dataa/da_supplier/index',
				role: ['20501', '20502', '20503'],
			}, {
				text: '仓库设置',
				img: '../../static/product.png',
				path: '/views/dataa/da_warehouse/index',
				role: ['20601', '20602', '20603'],
			},
		],
	}, {
		text: '客户管理',
		path: '/views/clientt',
		role: ['30101', '30102', '30103', '30105', '30201', '30202', '30203', '30301', '30302', '30303',
			'30306', '30401', '30402', '30403', '30405', '30501', '30502', '30503', '30505', '30601', '30602', '30603'],
		childrens: [
			{
				text: '客户列表',
				img: '../../static/clientt.png',
				path: '/views/clientt/cl_index/index',
				role: ['30101', '30102', '30103', '30105'],
			}, {
				text: '客户类型',
				img: '../../static/clientt.png',
				path: '/views/clientt/cl_classify/index',
				role: ['30201', '30202', '30203'],
			}, {
				text: '客户来源',
				img: '../../static/clientt.png',
				path: '/views/clientt/cl_source/index',
				role: ['30301', '30302', '30303', '30306'],
			}, {
				text: '客户备忘录',
				img: '../../static/clientt.png',
				path: '/views/clientt/cl_memo/index',
				role: ['30401', '30402', '30403', '30405'],
			}, {
				text: '客户投诉',
				img: '../../static/clientt.png',
				path: '/views/clientt/cl_complaint/index',
				role: ['30501', '30502', '30503', '30505'],
			}, {
				text: '客户回访',
				img: '../../static/clientt.png',
				path: '/views/clientt/cl_callback/index',
				role: ['30601', '30602', '30603'],
			}
		],
	}, {
		text: '订单管理',
		path: '/views/indent/index',
		role: ['40101', '40102', '40103', '40104',
			'40105', '40201', '40202', '40203', '40204', '40205', '40206', '40207',
			'40301', '40302', '40303', '40304', '40305', '40401', '40402', '40403', '40404', '40405'],
		childrens: [
			{
				text: '报价单',
				img: '../../static/dis_indent.png',
				path: '/views/order/o_quotation/index',
				role: ['40101', '40102', '40103', '40104', '40105'],
			}, {
				text: '销售订单',
				img: '../../static/dis_indent.png',
				path: '/views/order/o_sales/index',
				role: ['40201', '40202', '40203', '40204', '40205', '40206', '40207'],
			}, {
				text: '销售单发货',
				img: '../../static/dis_indent.png',
				path: '/views/order/o_sales_out/index',
				role: ['40301', '40302', '40303', '40304', '40305'],
			}, {
				text: '销售单退货',
				img: '../../static/dis_indent.png',
				path: '/views/order/o_sales_in/index',
				role: ['40401', '40402', '40403', '40404', '40405'],
			}
		],
	}, {
		text: '采购管理',
		path: '/views/purchase/index',
		role: ['50101', '50102', '50103', '50104', '50105', '50201', '50202', '50203', '50204', '50205', '50206',
			'50207', '50301', '50302', '50303', '50304', '50305', '50401', '50402', '50403', '50404', '50405'],
		childrens: [
			{
				text: '采购计划',
				img: '../../static/dis_purchase.png',
				path: '/views/purchase/pu_plan/index',
				role: ['50101', '50102', '50103', '50104', '50105'],
			}, {
				text: '采购单',
				img: '../../static/dis_purchase.png',
				path: '/views/purchase/pu_order/index',
				role: ['50201', '50202', '50203', '50204', '50205', '50206', '50207'],
			}, {
				text: '采购入库',
				img: '../../static/dis_purchase.png',
				path: '/views/purchase/pu_in/index',
				role: ['50301', '50302', '50303', '50304', '50305'],
			}, {
				text: '采购退货',
				img: '../../static/dis_purchase.png',
				path: '/views/purchase/pu_out/index',
				role: ['50401', '50402', '50403', '50404', '50405'],
			}
		],
	}, {
		text: '委外加工',
		path: '/views/purchase/index',
		role: ['60101', '60102', '60103', '60104', '60105', '60106', '60107', '60201', '60202', '60203', '60204',
			'60205', '60301', '60302', '60303', '60304', '60305', '60401', '60402', '60403', '60404', '60405', '60501', '60502', '60503'],
		childrens: [
			{
				text: '委外加工单',
				img: '../../static/dis_entrust.png',
				path: '/views/entrust/en_order/index',
				role: ['60101', '60102', '60103', '60104', '60105', '60106', '60107'],
			}, {
				text: '委外发料',
				img: '../../static/dis_entrust.png',
				path: '/views/entrust/en_material/index',
				role: ['60201', '60202', '60203', '60204', '60205'],
			}, {
				text: '委外补发料',
				img: '../../static/dis_entrust.png',
				path: '/views/entrust/en_material_tow/index',
				role: ['60301', '60302', '60303', '60304', '60305'],
			}, {
				text: '委外加工入库',
				img: '../../static/dis_entrust.png',
				path: '/views/entrust/en_in/index',
				role: ['60401', '60402', '60403', '60404', '60405'],
			}, {
				text: '加工商管理',
				img: '../../static/dis_entrust.png',
				path: '/views/entrust/en_business/index',
				role: ['60501', '60502', '60503'],
			}
		],
	}, {
		text: '生产管理',
		path: '/views/production/index',
		role: ['70201', '70202', '70203', '70204', '70205', '70206', '70207', '70208', '70302',
			'70303', '70304', '70305', '70306', '70307', '70401', '70402', '70403', '70404', '70405', '70501', '70601', '707',
			'70801', '70802', '70803', '70804', '70805', '70901', '70902', '70903', '70904', '70905', '701001', '701002',
			'701003', '701004', '701005'],
		childrens: [
			{
				text: '生产计划',
				img: '../../static/dis_production.png',
				path: '/views/production/p_plan/index',
				role: ['70201', '70202', '70203', '70204', '70205', '70206', '70207', '70208'],
			}, {
				text: '生产订单',
				img: '../../static/dis_production.png',
				path: '/views/production/p_order/index',
				role: ['70302', '70303', '70304', '70305', '70306', '70307'],
			}, {
				text: '生产领料单',
				img: '../../static/dis_production.png',
				path: '/views/production/p_material/index',
				role: ['70401', '70402', '70403', '70404', '70405'],
			}, {
				text: '工序报工',
				img: '../../static/dis_production.png',
				path: '/views/production/p_register/index',
				role: ['70501'],
			}, {
				text: '工序质检',
				img: '../../static/dis_production.png',
				path: '/views/production/p_check/index',
				role: ['70601'],
			}, {
				text: '已完成报工',
				img: '../../static/dis_production.png',
				path: '/views/production/p_finish/index',
				role: ['707'],
			}, {
				text: '生产入库',
				img: '../../static/dis_production.png',
				path: '/views/production/p_in/index',
				role: ['70801', '70802', '70803', '70804', '70805'],
			}, {
				text: '不良品入库',
				img: '../../static/dis_production.png',
				path: '/views/production/p_badness/index',
				role: ['70901', '70902', '70903', '70904', '70905'],
			}, {
				text: '报废品入库',
				img: '../../static/dis_production.png',
				path: '/views/production/p_scrap/index',
				role: ['701001', '701002', '701003', '701004', '701005'],
			},
		],
	}, {
		text: '仓库管理',
		path: '/views/warehouse/index',
		role: ['80101', '80102', '802', '80301', '80302', '80303', '80304', '80305', '80306', '80401', '80402',
			'80403', '80404', '80405', '80406', '80501', '80502', '80503', '80504', '80505', '80506', '80601', '80602',
			'80603', '80604', '80605', '80606', '80701', '80702', '80703', '80704', '80705', '80706', '80801', '80802',
			'80803', '80804', '80805', '80806', '80901', '80902', '80903', '80904', '80905', '80906', '801001', '801002',
			'801003', '801004', '801005', '801006', '801101', '801102', '801103', '801104', '801105', '801106', '801201',
			'801202', '801203', '801204', '801205', '801206', '801301', '801302', '801303', '801304', '801305', '801306', '8014'],
		childrens: [
			{
				text: '库存管理',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_inventory/index',
				role: ['80101', '80102'],
			}, {
				text: '仓库调拨',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_adjust/index',
				role: ['802'],
			}, {
				text: '采购入库',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_in_purchase/index',
				role: ['80301', '80302', '80303', '80304', '80305', '80306'],
			}, {
				text: '销售退货入库',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_in_out/index',
				role: ['80401', '80402', '80403', '80404', '80405', '80406'],
			}, {
				text: '委外加工入库',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_in_entrust/index',
				role: ['80501', '80502', '80503', '80504', '80505', '80506'],
			}, {
				text: '生产入库',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_in_product/index',
				role: ['80601', '80602', '80603', '80604', '80605', '80606'],
			}, {
				text: '不良品入库',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_in_badness/index',
				role: ['80701', '80702', '80703', '80704', '80705', '80706'],
			}, {
				text: '报废品入库',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_in_scrap/index',
				role: ['80801', '80802', '80803', '80804', '80805', '80806'],
			}, {
				text: '采购退货出库',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_out_purchase/index',
				role: ['80901', '80902', '80903', '80904', '80905', '80906'],
			}, {
				text: '销售发货出库',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_out_market/index',
				role: ['801001', '801002', '801003', '801004', '801005', '801006'],
			}, {
				text: '委外发料出库',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_entrust_material/index',
				role: ['801101', '801102', '801103', '801104', '801105', '801106'],
			}, {
				text: '委外补发料出库',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_out_entrust_b/index',
				role: ['801201', '801202', '801203', '801204', '801205', '801206'],
			}, {
				text: '生产领料出库',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_out_product/index',
				role: ['801301', '801302', '801303', '801304', '801305', '801306'],
			}, {
				text: '进出库明细',
				img: '../../static/dis_warehouse.png',
				path: '/views/warehouse/w_detail/index',
				role: ['8014'],
			}
		],
	}, {
		text: '人事管理',
		path: '/views/account/index',
		role: ['90101', '90102', '90103', '90104', '90201', '90202', '90203', '90204', '90301', '90302', '90303',
			'90304', '90305', '90401', '90402', '90403', '90405', '90501', '90502', '90503', '901001', '901002', '901003',
			'901201', '901202', '901203', '901204', '901301', '901302', '901303'],
		childrens: [
			{
				text: '部门管理',
				img: '../../static/account.png',
				path: '/views/account/ac_group/index',
				role: ['90101', '90102', '90103', '90104'],
			}, {
				text: '职位管理',
				img: '../../static/account.png',
				path: '/views/account/ac_job/index',
				role: ['90201', '90202', '90203', '90204'],
			}, {
				text: '员工管理',
				img: '../../static/account.png',
				path: '/views/account/ac_user/index',
				role: ['90301', '90302', '90303', '90304', '90305'],
			}, {
				text: '加班登记',
				img: '../../static/account.png',
				path: '/views/account/ac_overtime/index',
				role: ['90401', '90402', '90403', '90405'],
			}, {
				text: '缺勤登记',
				img: '../../static/account.png',
				path: '/views/account/ac_absenteeism/index',
				role: ['90501', '90502', '90503'],
			}, {
				text: '考勤管理',
				img: '../../static/account.png',
				path: '/views/account/ac_menology/index',
				role: ['901001', '901002', '901003'],
			}, {
				text: '通告类型',
				img: '../../static/account.png',
				path: '/views/account/ac_classify/index',
				role: ['901201', '901202', '901203', '901204'],
			}, {
				text: '通告记录',
				img: '../../static/account.png',
				path: '/views/account/ac_annunciate/index',
				role: ['901301', '901302', '901303'],
			}
		],
	}, {
		text: '财务管理',
		path: '/views/contract/index',
		role: ['999', '999999'],
		childrens: [
			{
				text: '账户管理',
				img: '../../static/finance.png',
				path: '/views/finance/bill/index',
				role: ['130101', '130102', '130103', '130104'],
			}, {
				text: '内部转账',
				img: '../../static/finance.png',
				path: '/views/finance/access/ac_transfer/index',
				role: ['130201', '130202', '130203'],
			}, {
				text: '实收资本',
				img: '../../static/finance.png',
				path: '/views/contract/con_apply/index',
				role: ['130301', '130302'],
			}, {
				text: '提现管理',
				img: '../../static/finance.png',
				path: '/views/contract/con_apply/index',
				role: ['130301', '130302'],
			}
		],
	}, {
		text: '合同管理',
		path: '/views/contract/index',
		role: ['999', '999999'],
		childrens: [
			{
				text: '合同列表',
				img: '../../static/contract.png',
				path: '/views/contract/con_list/index',
				role: ['130101', '130102', '130103', '130104'],
			}, {
				text: '合同类型',
				img: '../../static/contract.png',
				path: '/views/contract/con_classify/index',
				role: ['130201', '130202', '130203'],
			}, {
				text: '合同审核',
				img: '../../static/contract.png',
				path: '/views/contract/con_apply/index',
				role: ['130301', '130302'],
			}
		],
	}, {
		text: '设备管理',
		path: '/views/device/index',
		role: ['110101', '110102', '110103', '110201', '110202', '110203', '110204', '110205', '110301',
			'110302', '110303', '110304', '110305', '110405', '110406'],
		childrens: [
			{
				text: '设备档案',
				img: '../../static/device.png',
				path: '/views/device/de_list/index',
				role: ['110201', '110202', '110203', '110204', '110205'],
			}, {
				text: '设备类型',
				img: '../../static/device.png',
				path: '/views/device/de_classify/index',
				role: ['110101', '110102', '110103'],
			}, {
				text: '设备维修',
				img: '../../static/device.png',
				path: '/views/device/de_repair/index',
				role: ['110301', '110302', '110303', '110304', '110305'],
			}, {
				text: '待维修',
				img: '../../static/device.png',
				path: '/views/device/de_wait/index',
				role: ['110405', '110406'],
			}
		],
	}, {
		text: '系统管理',
		path: '/views/system/index',
		role: ['120101', '120102', '120103', '120104', '120105', '120201', '120202',
			'120203', '120204', '120301', '120303', '120304', '120305', '120401', '120402', '120403', '120404'],
		childrens: [
			{
				text: '账号管理',
				img: '../../static/system.png',
				path: '/views/system/sy_account/index',
				role: ['120101', '120102', '120103', '120104', '120105'],
			},
			//  {
			// 	text: '角色管理',
			// 	img: '../../static/system.png',
			// 	path: '/views/system/sy_role/index',
			// 	role: ['120201', '120202', '120203', '120204'],
			// }
		],
	},
];
let menu_list = ref([]);
const userinfo = uni.getStorageSync("userinfo");
const permissions = userinfo.permissions.split(',');
function setMenuList() {
	if (permissions.includes('999') || permissions.includes('999999')) {
		menu_list.value = routes
		return
	}
	menu_list.value = routes.
		filter(group => group.role.some(r => permissions.includes(r)))
		.map(v => {
			return {
				...v,
				childrens: v.childrens.filter(k => k.role.some(r => permissions.includes(r)))
			}
		})
}

function goPoster(path, text) {
	uni.navigateTo({
		//编码中文
		url: path + `?text=${text}`,
	});
};
setMenuList()

</script>

<style lang="scss">
.content {
	.icon-menu {
		font-size: 36rpx;
		padding-bottom: 60rpx;

		.menu_item {
			.item_tit {
				padding: 30rpx 25rpx 20rpx;
			}

			.icon_content {
				background-color: #fff;
				padding: 20rpx 25rpx;
				display: grid;
				grid-template-columns: repeat(4, 1fr);
				font-size: 24rpx;
				gap: 15rpx;

				.icon_item {
					text-align: center;
				}
			}
		}
	}
}
</style>